BEGIN { print "digraph " }

/search .*/ { print $3 " {" }

/^state / {
        match($0, / .*,/)
	lastState = "s" substr($0, RSTART + 1, RLENGTH - 2);
        lastStateLabel = substr($0, index($0, ": ") + 2) 
	print "\t" lastState " [label=" "\"" lastStateLabel "\"];"
}

/arc .*/ { 
	match($0, /\[label .*\]/);
        arcLabel = substr($0, RSTART + 7, RLENGTH - 8); 
	print "\t" lastState " -> s" $5 " [label=\"" arcLabel "\"];"
} 

END { print "}" }
